package cn.wzx.core.translation.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;

/**
 * @author wzx
 * @date 2024/11/11 10:54
 * @description: TranslatorConfiguration
 */
@Configuration
public class TranslatorConfiguration {

    @Autowired
    private Environment environment;


    @Bean
    public DataSource dataSource() {
        String url = environment.getProperty("util-plus.datasource.mysql.url");
        String username = environment.getProperty("util-plus.datasource.mysql.username");
        String password = environment.getProperty("util-plus.datasource.mysql.password");
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }

    @Bean
    public JdbcTemplate jdbcTemplate(DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }



}
